﻿<%@ Page Language="C#" MasterPageFile="~/ffl/ffl.master" AutoEventWireup="true" CodeFile="ImportMatches.aspx.cs"
    Inherits="ffl_admin_ImportMatches" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <form runat="server">
    <asp:DropDownList runat="server" ID="CompetitionDropDown"></asp:DropDownList>
    <asp:Button runat="server" ID="GetMatchesButton" onclick="GetMatchesButton_Click" Text="Import matches" />
    <asp:Panel runat="server" ID="MatchListPanel" Visible="false">
        <asp:DropDownList runat="server" ID="MonthDropDown" AutoPostBack="true" OnSelectedIndexChanged="monthDropDown_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:Repeater runat="server" ID="MatchRepeater" 
            OnItemCommand="MatchRepeater_ItemCommand" 
            onitemdatabound="MatchRepeater_ItemDataBound">
            <HeaderTemplate>
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="tableheader">
                            Date
                        </td>
                        <td class="tableheader" colspan="2">
                            Match
                        </td>
                        <td class="tableheader">
                            Action
                        </td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <asp:HiddenField runat="server" ID="EspnMatchIdHidden" Value='<%# DataBinder.Eval(Container.DataItem, "EspnMatchId") %>' />
                    <asp:HiddenField runat="server" ID="MatchDateHidden" Value='<%# ((DateTime)DataBinder.Eval(Container.DataItem, "MatchDate")).ToShortDateString() %>' />
                    <asp:HiddenField runat="server" ID="HomeClubIdHidden" Value='<%# DataBinder.Eval(Container.DataItem, "HomeClubId") %>' />
                    <asp:HiddenField runat="server" ID="AwayClubIdHidden" Value='<%# DataBinder.Eval(Container.DataItem, "AwayClubId") %>' />
                    <td>
                        <%# ((DateTime)DataBinder.Eval(Container.DataItem, "MatchDate")).ToShortDateString() %>
                    </td>
                    <td>
                        <%# DataBinder.Eval(Container.DataItem, "HomeClub") %>
                    </td>
                    <td>
                        <%# DataBinder.Eval(Container.DataItem, "AwayClub") %>
                    </td>
                    <td>
                        <asp:Button runat="server" ID="AddButton" Text="Add" />
                        <asp:Button runat="server" ID="EditButton" Text="Edit" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
    </asp:Panel>
    <asp:Panel runat="server" ID="PlayerListPanel" Visible="false">
        <asp:Label runat="server" ID="MatchDateLabel"></asp:Label>
        <asp:Label ID="MatchScoreLabel" runat="server"></asp:Label>
        <asp:HiddenField runat="server" ID="HomeClubIdHidden" />
        <asp:HiddenField runat="server" ID="HomeClubGoalsHidden" />
        <asp:HiddenField runat="server" ID="AwayClubIdHidden" />
        <asp:HiddenField runat="server" ID="AwayClubGoalsHidden" />
        <asp:Repeater runat="server" ID="PlayerListRepeater">
            <HeaderTemplate>
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td class="tableheader">
                            Player
                        </td>
                        <td class="tableheader">
                            Club
                        </td>
                        <td class="tableheader" align="center">
                            Started
                        </td>
                        <td class="tableheader" align="center">
                            Sub
                        </td>
                        <td class="tableheader" align="center">
                            Goals
                        </td>
                        <td class="tableheader" align="center">
                            (-0)
                        </td>
                        <td class="tableheader" align="center">
                            (-1)
                        </td>
                        <td class="tableheader" align="center">
                            (3+)
                        </td>
                    </tr>
            </HeaderTemplate>
            <ItemTemplate>
                <tr>
                    <asp:HiddenField runat="server" ID="PlayerIdHidden" Value='<%# GetPlayerId((Int32)DataBinder.Eval(Container.DataItem, "EspnPlayerId")) %>' />
                    <td>
                        <asp:Label runat="server" ID="PlayerNameLabel" Text='<%# GetPlayerName((Int32)GetPlayerId((Int32)DataBinder.Eval(Container.DataItem, "EspnPlayerId"))) %>'></asp:Label>
                    </td>
                    <td>
                        <asp:Label runat="server" ID="ClubLabel" Text='<%# GetClubName((Int32)DataBinder.Eval(Container.DataItem, "ClubId")) %>'></asp:Label>
                    </td>
                    <td align="center">
                        <asp:CheckBox runat="server" ID="StartedCheckBox" Checked='<%# DataBinder.Eval(Container.DataItem, "Started") %>' />
                    </td>
                    <td align="center">
                        <asp:CheckBox runat="server" ID="PlayedAsSubCheckBox" Checked='<%# DataBinder.Eval(Container.DataItem, "PlayedAsSub") %>' />
                    </td>
                    <td align="center">
                        <asp:TextBox runat="server" ID="GoalsTextBox" Width="30" Text='<%# DataBinder.Eval(Container.DataItem, "Goals") %>'></asp:TextBox>
                    </td>
                    <td align="center">
                        <asp:CheckBox runat="server" ID="CleanSheetCheckBox" Checked='<%# DataBinder.Eval(Container.DataItem, "CleanSheet") %>' />
                    </td>
                    <td align="center">
                        <asp:CheckBox runat="server" ID="ConcededOneCheckBox" Checked='<%# DataBinder.Eval(Container.DataItem, "ConcededOne") %>' />
                    </td>
                    <td align="center">
                        <asp:CheckBox runat="server" ID="TeamScoredThreePlusCheckBox" Checked='<%# DataBinder.Eval(Container.DataItem, "TeamScoredThreePlus") %>' />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <asp:Button runat="server" ID="UpdateButton" Text="Update" 
            onclick="UpdateButton_Click" />
    </asp:Panel>
    </form>
</asp:Content>
